using Godot;
using System;

public partial class Player : CharacterBody2D
{
	public const float RUN_SPEED = 30.0f;
	public const float JumpVelocity = -400.0f;
	public float gravity = (float) ProjectSettings.GetSetting("physics/2d/default_gravity");

	public override void _PhysicsProcess(double delta)
	{
		Vector2 velocity = Velocity;

		float direction = Input.GetAxis("move_left","move_right");

		velocity.X = direction * RUN_SPEED;

		velocity.Y += (float)(gravity * delta);

		if (IsOnFloor() && Input.IsActionJustPressed("jump")) {
			velocity.Y = JumpVelocity;
		}



		Velocity = velocity;
		MoveAndSlide();
	}
}
